package com.edu.his.service.impl;

import com.edu.his.domain.Register;
import com.edu.his.mapper.RegisterMapper;
import com.edu.his.service.RegisterService;
import com.edu.his.util.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 描述：
 * 创建人：飘
 * 创建时间：2024/12/16
 **/
@Service
public class RegisterServiceImpl implements RegisterService{

    @Autowired
    private RegisterMapper registerMapper;
    @Value("${com.edu.pagedSize}")
    private  Integer pageSize;

    @Override
    public R insert(Register register) {
        return R.success(200,"挂号添加成功",this.registerMapper.insert(register));
    }

    @Override
    public R getCaseNumber() {
        Object count=this.registerMapper.getCaseNumber();
        return R.success(200,"查询成功",count);
    }

    @Override
    public R getUseRegisterCount(Register register) {
        Object count=this.registerMapper.getUseRegisterCount(register);
        return R.success(200,"查询挂号总数",count);
    }

    @Override
    public R selectStatePage(Integer currPage,Register register) {
        List<Register> list=this.registerMapper.selectStatePage(register,(currPage-1)*pageSize,pageSize);
        int total=this.registerMapper.selectStatePageCount(register);

        return R.success(200,"查询成功",list,total);
    }

    @Override
    public R updateState(Register register) {
        return R.success(200,"修改状态成功",this.registerMapper.updateState(register));
    }

    @Override
    public R getRowCountRegisterState(Register register) {

        Object count=this.registerMapper.getRowCountRegisterState(register);
        return R.success(200,"查询人数成功",count);
    }

    @Override
    public R selectPatient(Register register) {
        Register register1=this.registerMapper.selectPatient(register);
        return R.success(200,"查询成功",register1);
    }

    @Override
    public R selectPatients(Integer currPage, Register register) {
        List<Register> list=this.registerMapper.selectPatients(register,(currPage-1)*this.pageSize,this.pageSize);
        int total=this.registerMapper.getSelectPatientsCount(register);
        return R.success(200,"查询成功",list,total);
    }
}
